<?php
// +-------------------------------------------------------------------
// |
// +-------------------------------------------------------------------
// | Copyright (c) 2009-2016 All rights reserved.
// +-------------------------------------------------------------------
namespace Service\Api\V1;

class UserStausPay
{
    public $login = true; //是否需要登录才能访问该接口
    public $title = "用户房租和物业缴费状态ok";
    public $group = '用户';
    public $desc = "";

    public $input = [
    ];

    public $output = [
        'house_pay_status' => 'label=房租缴纳状态;comment=0正常 1欠费',
        'service_pay_status' => 'label=物业费缴纳状态;;comment=0正常 1欠费',
    ];

    public function run($param, $uid, $login_info)
    {
        $result= [
            'house_pay_status' => 0,
            'service_pay_status' => 0,
        ];
        $house_contact = M('house_contract')->where(['uid' => $uid])->select();
        foreach($house_contact as $item){
            if($item['end_time']<date('Y-m-d')){
                $result['house_pay_status'] = 1;
            }
            if($item['service_end_time']<date('Y-m-d')){
                $result['service_pay_status'] = 1;
            }
        }
        return $result;
    }
}
